package com.yhsoft.buyer.controller;

import com.yhsoft.buyer.controller.request.UserDeleteInVo;
import com.yhsoft.buyer.controller.request.UserQueryInVo;
import com.yhsoft.buyer.controller.request.UserUpdateInVo;
import com.yhsoft.buyer.controller.response.BuyerUserOutVo;
import com.yhsoft.buyer.service.IBuyerUserService;
import com.yhsoft.common.response.PageResult;
import com.yhsoft.common.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * <p>
 * 买家 前端控制器
 * </p>
 *
 * @author yyyyyyyh
 * @since 2023-09-26
 */
@Api(tags = {"F-小程序用户管理接口"})
@RestController
@RequestMapping("/buyer/buyerUser")
public class BuyerUserController {
    @Resource
    private IBuyerUserService buyerUserService;


    @ApiOperation("列表")
    @GetMapping("/getBuyerUserList")
    public Result<PageResult<BuyerUserOutVo>> getBuyerUserList(UserQueryInVo inVo,
                                                         @RequestParam(value = "pageNo") Long pageNo,
                                                         @RequestParam(value = "pageSize") Long pageSize){
        PageResult<BuyerUserOutVo> list =  buyerUserService.getBuyerUserList(inVo, pageNo,pageSize);
        return Result.success(list);
    }

    @ApiOperation("详情")
    @GetMapping("/getBuyerUser")
    public Result<BuyerUserOutVo> getBuyerUser(@NotNull(message = "小程序用户id不能为空") @RequestParam String id){
        BuyerUserOutVo outVo =  buyerUserService.getBuyerUser(id);
        return Result.success(outVo);
    }

    @ApiOperation("修改用户状态")
    @PostMapping("/update")
    public Result<?> updateStatus(@RequestBody UserUpdateInVo inVo){
        buyerUserService.updateStatus(inVo);
        return Result.success();
    }

    @ApiOperation("删除用户")
    @PostMapping("/delete")
    public Result<?> delete(@RequestBody UserDeleteInVo inVo){
        buyerUserService.delete(inVo);
        return Result.success();
    }
}
